<template>
	
	<view class="index-list animated fadeInLeft faster">
		<view class="index-list1">
			<view>
				<image :src="item.userpic" mode="widthFix" lazy-load></image>
				{{item.username}}
			</view>
			<view v-show="!isguanzhu" @tap="guanzhu">
				<view class="icon iconfont icon-zengjia" ></view>
				关注
			</view>
	
		</view>
		<view class="index-list2" @tap="opendetail">{{item.title}}</view>
		<view class="index-list3" @tap="opendetail">
			<!-- 图片 -->
			<image :src="item.titlepic" mode="widthFix" lazy-load></image>
			<!-- 视频 -->
			<template v-if="item.type=='video'">
				<view class="index-list-play icon iconfont icon-bofang"></view>
				<view class="index-list-playinfo">
					{{item.playnum}} 次播放 {{item.long}}
				</view>
	
			</template>
	
		</view>
		<view class="index-list4">
			<view>
				<view :class="{'active':(infonum.index==1)}" @tap="caozuo('ding')">
					<view class="icon iconfont icon-icon_xiaolian-mian"></view>{{infonum.dingnum}}
				</view>
				<view :class="{'active':(infonum.index==2)}" @tap="caozuo('cai')">
					<view class="icon iconfont icon-kulian"></view>{{infonum.cainum}}
				</view>
			</view>
			<view>
				<view>
					<view class="icon iconfont icon-pinglun1"></view>{{item.commentnum}}
				</view>
				<view>
					<view class="icon iconfont icon-zhuanfa"></view>{{item.sharenum}}
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	
	export default {
		props:{
			item:Object,
			index:Number
		},
		data() {
			return {
				isguanzhu:this.item.isguanzhu,
				infonum:this.item.infonum
			}
		},
		methods:{
			// 关注事件
			guanzhu(){
				this.isguanzhu=true;
				uni.showToast({
				    title: '已关注'
				    
				});
			},
			caozuo(type){
				switch (type) {
					case "ding":
						if(this.infonum.index==1){
							return;
						}
						this.infonum.dingnum++;
						if(this.infonum.index==2){
							this.infonum.cainum--;
						}
						this.infonum.index=1;
					break;
					case "cai":
						if(this.infonum.index==2){
							return;
						}
						this.infonum.cainum++;
						if(this.infonum.index==1){
							this.infonum.dingnum--;
						}
						this.infonum.index=2;
					break;
				}
				
			},
			//进入详情页面
			opendetail(){
				uni.navigateTo({
					//跳转到内容详情页，并把内容传值到内容页（转换格式）
					url: '../../pages/detail/detail?detailData='+JSON.stringify(this.item),
				});
			}
			
		}
		
	}
	
	
	
	
	
</script>

<style scoped>
	/* 封装公共样式 直接类名加上class*/
	.u-f {
		display: flex;
		align-items: center;
	}
	
	
	
	.index-list {
		padding: 20upx;
		border-bottom: 1upx solid #EEEEEE;
	}
	
	.index-list1 {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.index-list1>view:first-child {
		display: flex;
		align-items: center;
	}
	
	.index-list1>view:first-child image {
		width: 80upx;
		height: 80upx;
		border-radius: 100%;
		margin-right: 20upx;
	}
	
	.index-list1>view:last-child {
		display: flex;
		align-items: center;
		background: #F4F4F4;
		border-radius: 5upx;
		padding: 0 10upx;
	}
	
	.index-list2 {
		padding-top: 15upx;
		font-size: 32upx;
	}
	
	.index-list3 {
		position: relative;
		padding-top: 15upx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.index-list3 image {
		width: 100%;
		border-radius: 20upx;
	}
	
	.index-list-play {
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		font-size: 120upx;
		color: #FFFFFF;
	}
	
	.index-list-playinfo {
		position: absolute;
		background: rgba(51, 51, 51, 0.72);
		color: #FFFFFF;
		border-radius: 40upx;
		bottom: 8upx;
		right: 8upx;
		font-size: 20upx;
		padding: 0 12upx;
	
	}
	
	.index-list4 {
		padding: 15upx 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.index-list4 view {
		color: #999999;
	}
	
	.index-list4>view:first-child {
		display: flex;
		align-items: center;
	}
	
	.index-list4>view:last-child {
		display: flex;
		align-items: center;
	}
	
	.index-list4>view>view {
		display: flex;
		align-items: center;
	}
	
	.index-list4>view>view>view {
		margin-right: 10upx;
	}
	
	.index-list4>view>view:first-child {
		margin-right: 10upx;
	}
	
	.index-list4 .active,
	.index-list4 .active>view {
		color: #C5F61C;
	
	
	}
	
</style>
